<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改项目成员/外派人员')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-project-member-edit" th:object="${projectMember}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">项目名称：</label>
                <div class="col-sm-8">
                    <input name="projectId" type="hidden" th:value="*{projectId}">
                    <input name="projectName" class="form-control" type="text" th:field="*{project.shortTitle}"  disabled>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">员工姓名：</label>
                <div class="col-sm-8">
                    <select name="userId"  class="form-control m-b" th:field="*{userId}" required disabled th:with="type=${@customDictService.selectDictOnboardStaff()}">
                        <option value="">--请选择--</option>
                        <option th:each="dict : ${type}" th:text="${dict.name} + '(' + ${dict.idNumber} + ')'" th:value="${dict.userId}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">岗位：</label>
                <div class="col-sm-8">
                    <select name="postId" class="form-control m-b" th:field="*{postId}" th:disabled="${isDepart}" >
                        <option value="">请选择</option>
                        <option th:each="post:${posts}" th:value="${post.postId}" th:text="${post.postName}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">进场时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="onboardTime" th:value="${#dates.format(projectMember.onboardTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" th:disabled="${isDepart}">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label" th:required="${isDepart}">离场时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="departTime" th:value="${#dates.format(projectMember.departTime, 'yyyy-MM-dd')}" th:required="${isDepart}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group" th:hidden="${isDepart}">
                <label class="col-sm-3 control-label">进场场状态：</label>
                <div class="col-sm-8">
                    <select name="onboardStatus" class="form-control m-b" th:with="type=${@dict.getType('project_onboard_status')}"th:if="${!isDepart}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{onboardStatus}"></option>
                    </select>
                    <input type="hidden" name="onboardStatus" value="depart" th:if="${isDepart}" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="description" class="form-control">[[*{description}]]</textarea>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "erp/project/" +[[${projectMember.getProjectId()}]] + "/member";
        $("#form-project-member-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-project-member-edit').serialize());
            }
        }

        $("input[name='onboardTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='departTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    </script>
</body>
</html>